#ifndef __TIMER_H__
#define __TIMER_H__

typedef struct timer_t {
  uint8_t started : 1;
  uint8_t periodic : 1;

  uint16_t period;
  uint32_t expired;

  void (*run)(void);

  struct timer_t *prev;
  struct timer_t *next;
} timer_t;

void TIMER_init(void);
void TIMER_run(void);

void TIMER_reg(timer_t *t, void (*run)(void));

void TIMER_start(timer_t *t, uint16_t time);
void TIMER_startPeriodic(timer_t *t, uint16_t time);
void TIMER_stop(timer_t *t);

#endif // __TIMER_H__
